package cate.common.table.pvp.arena.challenge_reward;

import cate.common.table.ESheet;
import easy.java.dev.note.NoteClass;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

@NoteClass("跨服擂台赛-跨服擂台赛挑战奖励")
public class ArenaChallengeRewardSheet extends ESheet<ArenaChallengeRewardRow> {
    @Override
    public String getSheetName() {
        return "跨服擂台赛挑战奖励";
    }

    /**
     * 获取指定数量的随机奖励
     *
     * @param type 奖励种类
     * @param num 随机数量
     */
    public List<ArenaChallengeRewardRow> getRandomRewards(int type, int num) {
        List<ArenaChallengeRewardRow> typeRows = getList().stream().filter(row -> row.type == type)
                .collect(Collectors.toList());
        Collections.shuffle(typeRows);
        if (typeRows.size() <= num) {
            return typeRows;
        }
        return typeRows.subList(0, num);
    }
}
